﻿using Magicodes.ExporterAndImporter.Excel.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using NP.BPMReportPlatform.HYT.Dto;
using NP.BPMReportPlatform.MaterialMasterData.Dto;
using NP.BPMReportPlatform.MaterialMasterData.Dtos;
using NP.BPMReportPlatform.RestfulApis.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;

namespace NP.BPMReportPlatform.HYT
{
    /// <summary>
    /// 回用桶出货
    /// </summary>
    [ApiController]
    [Route("api/HYTCH")]
    public class HYTCHController : BPMReportPlatformController
    {
        public readonly IHYTCHService _service;
        public HYTCHController(IHYTCHService service)
        {
            _service = service;
        }

        [Authorize]
        [HttpPost]
        [Route("GetAllAsync")]
        public async Task<PagedResultDto<HYTCHDto>> GetAllAsync([FromBody] HYTInput input)
        {
            return await _service.GetAllAsync(input);
        }

        [Authorize]
        [HttpPost]
        [Route("ExportAsync")]
        public async Task<XlsxFileResult<HYTCHDto>> ExportAsync([FromBody] HYTInput input)
        {
            var rst = await _service.ExportAsync(input);            
            return new XlsxFileResult<HYTCHDto>(rst, "导出Excel");
        }

        [Authorize]
        [HttpPost]
        [Route("Edit")]
        public async Task<string> Edit([FromBody] HYTEditInput input)
        {
            return await _service.Eidt(input);
        }

        [Authorize]
        [HttpPost]
        [Route("ReSync")]
        public async Task<ApiResultDto> ReSync([FromBody] HYTReSyncInput input)
        {
            return await _service.ReSync(input);
        }

        /// <summary>
        /// 根据BPM单号获取出货详情，ESB接口
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost("GetBucketOutStockDetail")]
        public async Task<List<GetBucketOutStockDetailDto>> GetBucketOutStockDetail([FromBody] GetBucketOutStockDetailInput input)
        {
            return await _service.GetBucketOutStockDetail(input);
        }
    }
}
